package com.hospital.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hospital.domain.pojo.Reservation;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface ReservationMapper extends BaseMapper<Reservation> {
    
    @Select("SELECT r.*, p.pname, d.dname, dep.depName, s.date, s.time " +
            "FROM reservation r " +
            "LEFT JOIN patient p ON r.pId = p.pid " +
            "LEFT JOIN schedule s ON r.sId = s.sid " +
            "LEFT JOIN doctor d ON s.dId = d.did " +
            "LEFT JOIN department dep ON s.depId = dep.depId " +
            "ORDER BY r.rTime DESC")
    List<Map<String, Object>> queryAllReservationsWithInfo();
}
